package com.ys.zero.web;

import java.io.IOException;

import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ys.zero.bean.Uarticle;
import com.ys.zero.bean.User;
import com.ys.zero.dao.UserbackDao;


@WebServlet("/manage/*")
public class ManageServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	
	UserbackDao dao = new UserbackDao();
       
	protected void show(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		User user = (User) request.getSession().getAttribute("loginedUser");
		
		List<Uarticle> list = dao.getArticle(user.getId());
		
		toJson(response,list);
	}
	
	protected void delArticle(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String uaid = request.getParameter("uaid");
		dao.delArticle(uaid);
	}
	
	protected void MpShow(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String id = request.getParameter("id");
		List<Uarticle> list = dao.getArticle(Integer.parseInt(id));
		
		toJson(response,list);
	}
	/**
	 * 个人页面收藏
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 */
	protected void MyCollaction(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		User user = (User) request.getSession().getAttribute("loginedUser");
		List<Map<String, Object>>  list = dao.MyCollaction(user.getAccount());
		toJson(response, list);
	}
}
